package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.mapper.EmployeeMapper;
import com.itheima.pojo.Employee;
import com.itheima.service.EmployeeService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService{
    @Override
    public Page<Employee> selectPage(String name,Integer page, Integer pageSize) {

        //创建条件对象
        QueryWrapper<Employee> wrapper=new QueryWrapper<>();
        //模糊查询
        wrapper.like(StringUtils.isNotBlank(name),"name",name);
        //排序
        wrapper.orderByDesc("create_time");
        Page<Employee> pageInfo = this.page(new Page<>(page, pageSize), wrapper);
      /*  Page<Employee> employeePage = new Page<>();
         employeePage.setTotal(pageInfo.getTotal());
         employeePage.setPages(pageInfo.getPages());*/
        return pageInfo;
    }
}
